//
//  PicPickerViewCell.swift
//  Weibo
//
//  Created by 孙国强 on 2017/7/5.
//  Copyright © 2017年 孙国强. All rights reserved.
//

import UIKit

class PicPickerViewCell: UICollectionViewCell {
    // MARK:- 控件属性
    @IBOutlet weak var addPhotoBtn: UIButton!
    @IBOutlet weak var removePhotoBtn: UIButton!
    @IBOutlet weak var imageView: UIImageView!
    
    // MARK:- 定义属性
    var image : UIImage? {
        didSet {
            if image != nil {
                imageView.image = image
                addPhotoBtn.isUserInteractionEnabled = false
                removePhotoBtn.isHidden = false
            } else {
                imageView.image = nil
                addPhotoBtn.isUserInteractionEnabled = true
                removePhotoBtn.isHidden = true
            }
        }
    }
    
    @IBAction func addPhotoBtnClick(_ sender: Any) {
        NotificationCenter.default.post(name: Notification.Name(PicPickerAddPhotoNote), object: nil)
    }
    @IBAction func removePhotoClick(_ sender: Any) {
        NotificationCenter.default.post(name: NSNotification.Name(PicPickerRemovePhotoNote), object: imageView.image)
    }
    
}
